package com.aaa.member.controller;

import com.aaa.common.constants.ReturnCode;
import com.aaa.common.util.Result;
import com.aaa.member.entity.IntegrationHistory;
import com.aaa.member.service.IntegrationHistoryService;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 * (IntegrationHistory)表控制层
 *
 * @author LiangLei
 * @since 2020-11-19 14:46:57
 */
@RestController
@RequestMapping("integrationHistory")
public class IntegrationHistoryController {
    /**
     * 服务对象
     */
    @Resource
    private IntegrationHistoryService integrationHistoryService;

    /**
     * 通过主键查询单条数据
     *
     * @param id 主键
     * @return 单条数据
     */
    @GetMapping("selectOne")
    public IntegrationHistory selectOne(Integer id) {
        return this.integrationHistoryService.queryById(id);
    }

    /**
     *  分页
     */
    @GetMapping("queryPageByParam")
    Result queryPageByParam(Integer pageNo, Integer pageSize, IntegrationHistory integrationHistory){
        return this.integrationHistoryService.queryPageByParam(pageNo,pageSize,integrationHistory);
    }



    @PostMapping("add")
    public Result add(@RequestBody IntegrationHistory integrationHistory){
        //返回成功
        return new Result(ReturnCode.SUCCESSS.getCode(),
                ReturnCode.SUCCESSS.getMsg(),this.integrationHistoryService.insert(integrationHistory));
    }



    @DeleteMapping("delete")
    public Result delete(Integer id){
        //返回成功
        return new Result(ReturnCode.SUCCESSS.getCode(),
                ReturnCode.SUCCESSS.getMsg(),this.integrationHistoryService.deleteById(id));
    }




    /**
     * 更新
     * @param integrationHistory
     * @return
     */
    @PutMapping("update")
    public Result update(@RequestBody IntegrationHistory integrationHistory){
        return new Result(ReturnCode.SUCCESSS.getCode(),
                ReturnCode.SUCCESSS.getMsg(),this.integrationHistoryService.update(integrationHistory));
    }
}